package logic

import (
	"context"
	"go-zero-demo-04/mall/result/api/ResultModel"

	"go-zero-demo-04/mall/result/api/internal/svc"
	"go-zero-demo-04/mall/result/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PutAnswerLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPutAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PutAnswerLogic {
	return &PutAnswerLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PutAnswerLogic) PutAnswer(req *types.PutAnswerRequest) (resp *types.PutAnswerResponse, err error) {
	newAnswer := ResultModel.Answer{
		TestTime: req.Time,
		Answer1:  req.Answer1,
		Answer2:  req.Answer2,
		Answer3:  req.Answer3,
		Answer4:  req.Answer4,
		Answer5:  req.Answer5,
		Answer6:  req.Answer6,
		Answer7:  req.Answer7,
		Answer8:  req.Answer8,
		Answer9:  req.Answer9,
		Answer10: req.Answer10,
		Answer11: req.Answer11,
		Answer12: req.Answer12,
		Answer13: req.Answer13,
		Answer14: req.Answer14,
		Answer15: req.Answer15,
		Answer16: req.Answer16,
		Answer17: req.Answer17,
		Answer18: req.Answer18,
		Answer19: req.Answer19,
		Answer20: req.Answer20,
		Answer21: req.Answer21,
		Answer22: req.Answer22,
		Answer23: req.Answer23,
		Answer24: req.Answer24,
		Answer25: req.Answer25,
		Answer26: req.Answer26,
		Answer27: req.Answer27,
		Answer28: req.Answer28,
		Answer29: req.Answer29,
		Answer30: req.Answer30,
		Answer31: req.Answer31,
		Answer32: req.Answer32,
		Answer33: req.Answer33,
		Answer34: req.Answer34,
		Answer35: req.Answer35,
		Answer36: req.Answer36,
		Answer37: req.Answer37,
		Answer38: req.Answer38,
		Answer39: req.Answer39,
		Answer40: req.Answer40,
		Answer41: req.Answer41,
		Answer42: req.Answer42,
		Answer43: req.Answer43,
		Answer44: req.Answer44,
		Answer45: req.Answer45,
		Answer46: req.Answer46,
		Answer47: req.Answer47,
		Answer48: req.Answer48,
		Answer49: req.Answer49,
		Answer50: req.Answer50,
		Answer51: req.Answer51,
		Answer52: req.Answer52,
		Answer53: req.Answer53,
		Answer54: req.Answer54,
		Answer55: req.Answer55,
		Answer56: req.Answer56,
		Answer57: req.Answer57,
		Answer58: req.Answer58,
		Answer59: req.Answer59,
		Answer60: req.Answer60,
		Answer61: req.Answer61,
		Answer62: req.Answer62,
		Answer63: req.Answer63,
		Answer64: req.Answer64,
		Answer65: req.Answer65,
		Answer66: req.Answer66,
		Answer67: req.Answer67,
		Answer68: req.Answer68,
		Answer69: req.Answer69,
		Answer70: req.Answer70,
		Answer71: req.Answer71,
		Answer72: req.Answer72,
		Answer73: req.Answer73,
		Answer74: req.Answer74,
		Answer75: req.Answer75,
		Answer76: req.Answer76,
		Answer77: req.Answer77,
		Answer78: req.Answer78,
		Answer79: req.Answer79,
		Answer80: req.Answer80,
		Answer81: req.Answer81,
		Answer82: req.Answer82,
		Answer83: req.Answer83,
		Answer84: req.Answer84,
		Answer85: req.Answer85,
		Answer86: req.Answer86,
		Answer87: req.Answer87,
		Answer88: req.Answer88,
		Answer89: req.Answer89,
		Answer90: req.Answer90,
		Answer91: req.Answer91,
		Answer92: req.Answer92,
		Answer93: req.Answer93,
	}

	_, err = l.svcCtx.AnswerModel.Insert(l.ctx, &newAnswer)

	if err != nil {
		return nil, err
	}

	return &types.PutAnswerResponse{
		Result: "存入成功",
	}, nil
}
